package com.myapp.ruyixing.http;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.myapp.ruyixing.model.MyPictureList;

public class MyPictureListParser extends RYJSONParser {
	@Override
	public Object parse(JSONObject jsonObject) {
		MyPictureList pictureList = new MyPictureList();

		ListModelParser.parseListModel(pictureList, jsonObject);
		JSONObject data = jsonObject.optJSONObject("data");
		JSONArray array = data.optJSONArray("items");
		pictureList.items = new ArrayList<MyPictureList.Picture>();
		for (int i = 0; array != null && i < array.length(); i++) {
			JSONObject object = array.optJSONObject(i);
			if (object != null) {
				MyPictureList.Picture picture = new MyPictureList.Picture();
				picture.picurl = object.optString("picurl", "");
				picture.title = object.optString("title", "");
				pictureList.items.add(picture);
			}
		}

		return pictureList;

	}
}
